from quote_folder.Db_connect import *
import pymysql
conn = pymysql.connect(host="112.125.25.114", port=3306, user='python', password='pythonselect', db="mykhadmin", use_unicode=True, charset='utf8')
cur = conn.cursor()

conn_1 = pymysql.connect(host="121.4.69.146", user='root', password='xhhg@2020', port=3306, db="big_data", use_unicode=True, charset='utf8')
cur_1 = conn_1.cursor()

# with open("sqh.txt", "r") as fw:
#     ss = 0
#     for application_number in fw:
#         sqh = "ZL" + application_number.strip()
#         sql = f"SELECT order_number, unique_number FROM `finals` WHERE application_number = '{sqh}'"
#         cur.execute(sql)
#         data = cur.fetchall()
#         try:
#             order_num = data[0][1]
#             sql_1 = f'SELECT liaisons, liaisons_tel FROM orders where order_number = "{order_num}"'
#             cur.execute(sql_1)
#             data_1 = cur.fetchall()
#             print(data[0][0], data_1[0][0], data_1[0][1])
#         except:
#             print("跳过")

with open("sqh.txt", "r") as fw:
    ss = 0
    for application_number in fw:
        sqh = application_number.strip()
        sql = f"SELECT fwr FROM `CPCFlieUploadResult` WHERE file_type LIKE '%证书%' and sqh = '{sqh}'"
        print(sql)
        cur_1.execute(sql)
        data = cur_1.fetchall()
        try:
            order_num = data[0][0]
            print(order_num)
        except:
            print("跳过")


